<template>
  <div>
    <!-- 浮动导航 -->
    <div class="float-link-container">
      <FloatMallLinkComponent/>
    </div>

    <!-- 页面主体 -->
    <div class="main-container">
      <div class="cart">
        <div class="cart-filter-bar">
          <span class="switch-cart">购物车（全部{{ checkAmountNum }}）</span>
          <div class="cart-sum">
            <span class="pay-text">已选商品（不含运费）</span>
            <strong class="price">
              <span class="total-symbol">&nbsp;</span>{{ checkedCountMoney }}
            </strong>
            <a class="submit-btn submit-btn-disabled">结算</a>
          </div>
        </div>
        <div class="cart-main">
          <div class="cart-table-th">
            <div class="th th-chk">
              <div class="select-all J_SelectAll">
                <div class="cart-checkbox">
                  <el-checkbox :indeterminate="isIndeterminate" v-model="allChecked" @change="handleCheckAllChange">
                    全选
                  </el-checkbox>

                </div>
              </div>
            </div>
            <div class="th th-item">
              <div class="td-inner">商品信息</div>
            </div>
            <div class="th th-price">
              <div class="td-inner">单价</div>
            </div>
            <div class="th th-amount">
              <div class="td-inner">数量</div>
            </div>
            <div class="th th-sum">
              <div class="td-inner">金额</div>
            </div>
          </div>
          <div class="cart-now-list">
            <el-checkbox-group v-model="checkedCartItem" @change="handleCheckedCitiesChange">
              <el-checkbox v-for="item in cartList" :label="item" :key="item" style="height: auto;">
                <div class="order-body">
                  <div class="order-content">
                    <div class="item-list">
                      <ul class="item-content">
                        <li class="td td-item">
                          <div class="td-inner">
                            <a :href="item.commodityDetail" target="_blank"
                               class="item-title J_GoldReport J_MakePoint">{{ item.cartItemTitle }}</a>
                          </div>
                        </li>
                        <li class="td td-price">
                          <div class="td-inner">
                            ￥{{ item.itemSinglePrice }}
                          </div>
                        </li>
                        <li class="td td-amount">
                          <div class="td-inner">
                            <el-input-number v-model="item.itemCount" @change="handleChange" :min="1" :max="10"
                                             label="描述文字"
                                             size="mini">
                            </el-input-number>
                          </div>
                        </li>
                        <li class="td td-sum">
                          <div class="td-inner">￥{{ item.itemAllPrice }}
                          </div>
                        </li>
                      </ul>
                    </div>
                  </div>
                </div>
              </el-checkbox>
            </el-checkbox-group>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import FloatMallLinkComponent from '@/components/FloatMallLinkComponentView.vue';

export default {
  components: {
    FloatMallLinkComponent
  },
  data() {
    return {
      checkedCartItem: [],
      isIndeterminate: false,
      allChecked: false,
      checkedCountMoney: 0.0,
      checkAmountNum: 0,
      cartList: [
        {
          cartItemId: 1,
          cartItemTitle: "2023年明前特级信阳毛尖绿茶 250克（125g*2罐）",
          itemSinglePrice: 216,
          itemAllPrice: 216,
          commodityDetail: "",
          itemCount: 1
        },
        {
          cartItemId: 2,
          cartItemTitle: "2023年明前特级信阳毛尖绿茶 250克（125g*2罐）",
          itemSinglePrice: 216,
          itemAllPrice: 216,
          commodityDetail: "",
          itemCount: 1
        },
        {
          cartItemId: 3,
          cartItemTitle: "2023年明前特级信阳毛尖绿茶 250克（125g*2罐）",
          itemSinglePrice: 216,
          itemAllPrice: 216,
          commodityDetail: "",
          itemCount: 1
        },


      ]
    }
  },
  methods: {
    handleChange(value) {
      console.log(value);
    },
    loadPageTitle() {
      this.pageTitle = '茶叶商城 - 学茶商城网';
      document.title = this.pageTitle;
    },
    loadDefaultSearchKeywords() {
      let defaultSearchKeywords = '大红袍';
      this.defaultSearchKeywords = defaultSearchKeywords;
    },
    loadSearchSuggestKeywords() {
      let searchSuggestKeywords = ['车载杯', '煮茶壶', '铁观音', '五宝茶', '小青柑', '苦荞茶'];
      this.searchSuggestKeywords = searchSuggestKeywords;
    },
    handleCheckAllChange(val) {
      this.checkedCartItem = val ? this.cartList : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.allChecked = checkedCount === this.cartList.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.cartList.length;
    }

  },
  mounted() {
    this.loadPageTitle();
    this.loadDefaultSearchKeywords();
    this.loadSearchSuggestKeywords();

  },
  created() {

  }
}
</script>

<style>
a {
  color: #3c3c3c;
}

.main-container {
  text-align: left !important;
  width: 1200px;
  margin: 0 auto;
}

.cart {
  margin-top: 24px;
  min-height: 400px;
  background-color: #fff;
  -webkit-border-radius: 24px;
  -moz-border-radius: 24px;
  -ms-border-radius: 24px;
  border-radius: 24px;
  overflow: hidden;
}

.cart-filter-bar {
  overflow: hidden;
  font-size: 12px;
  position: relative;
  height: 72px;
  padding: 0 18px;
  border-bottom: 1px solid #e6e6e6;
}

.switch-cart {
  overflow: hidden;
  color: #000;
  font-size: 18px;
  font-weight: 600;
  height: 72px;
  line-height: 72px;
}

.cart-filter-bar .cart-sum {
  position: absolute;
  right: 18px;
  top: 0;
  height: 72px;
  line-height: 72px;
  font-size: 14px;
}

.cart-sum .pay-text {
  position: relative;
  top: -2px;
}

.cart-sum .price {
  font-family: Arial, Verdana;
  font-weight: 400;
  margin-right: 12px;
  font-size: 22px;
  color: #FF5000;
}

.cart-sum .submit-btn {
  display: inline-block;
  width: 74px;
  height: 42px;
  line-height: 42px;
  color: #fff;
  background: #FF5000;
  -webkit-border-radius: 21px;
  -moz-border-radius: 21px;
  -ms-border-radius: 21px;
  border-radius: 21px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  top: -2px;
  font-size: 16px;
}

.item-list {
  margin-left: 30px;
}

.cart-main {
  min-height: 210px;
}

.cart-table-th {
  margin-left: 60px;
  overflow: hidden;
  height: 50px;
  line-height: 50px;
  color: #3c3c3c;
  font-weight: 700;
}

.cart-table-th .th {
  float: left;
}

.cart-table-th .th-chk {
  margin-right: 10px;
  font-size: 12px;
  text-align: left;
  position: relative;
  height: 50px;
}

.th-item, .td-item {
  margin-right: 10px;
  width: 45%;
}

.th-price, .td-price {
  width: 15%;
}

.th-amount, .td-amount {
  width: 15%;
}

.th-sum, .td-sum {
  width: 15%;
}

.order-body {
  margin-bottom: 15px;
  *position: relative;
}

.cart-now-list .el-checkbox {
  width: 100% !important;
}

.order-content {
  border: 1px solid #F5F5F5;
  background-color: #F5F5F5;
  -webkit-border-radius: 18px;
  -moz-border-radius: 18px;
  -ms-border-radius: 18px;
  border-radius: 18px;
  margin: 0 24px;
  overflow: hidden;
}

.cart-now-list .el-checkbox__input {
  margin: 10px;
}

.cart-now-list .el-checkbox__label {
  width: 97%;
}


.item-content {
  padding-right: 12px;

}

.item-content .td-inner {
  padding-top: 20px;
  _zoom: 1;

}

.item-content .td-chk {
  margin-right: 10px;
  position: relative;
  overflow: hidden;
}

.item-content .td {
  float: left;
  min-height: 119px;
  _height: 119px;
  overflow: hidden;
  _overflow: visible;
  _zoom: 1;
}

.item-content .td-price {
  color: #9c9c9c;
  text-align: center;
}


.item-content .td-sum {
  color: #f40;
  font-weight: 700;
  text-align: center;
}
</style>
